var config = require('config');
cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function () {
        var random = Math.random();
        var index = random * 10 | 0 + 1;
        cc.log("random card " + index);
        // var index = config.cardid;
        cc.log("get wards:"+index);
        // var url = config.cardurl;
        if(index > 0){
            var cardstring = "wards/boom"+index;
            var self = this;
            cc.loader.loadRes(cardstring, cc.SpriteFrame, function (err, spriteFrame) {
                self.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });
        }
        
    },
    
    openWeb: function () {
        var url = config.cardurl;
        cc.log("url:" + url);
        window.open(url,'领奖');
    }

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
